﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data;

namespace SettingsLib.Ceny
{
    /// <summary>
    /// Interaction logic for CenyWin.xaml
    /// </summary>
    public partial class CenyWin : Window
    {
        public CenyWin()
        {
            InitializeComponent();
        }

        private void CenyWin_Loaded_1(object sender, RoutedEventArgs e)
        {
       //    DataLib.Settings.databases.dbCeny.loadAllSortTo(("prefix", "Ceny",lis
            DataLib.Settings.databases.dbCeny.loadAllSortTo("prefix", "Ceny", lstvCeny);
        }

        private void CreateRuleMenuItem_Click_1(object sender, RoutedEventArgs e)
        {
            
        }

        private void DeleteRuleMenuItme_Click_1(object sender, RoutedEventArgs e)
        {

        }

        private void btnUlozit_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            DataTable table = ((DataView)lstvCeny.DataContext).ToTable();
            DataLib.Settings.databases.dbCeny.UpdateTable(table, "Ceny");
        }

        private void ConMenuUpravitObednavka_Click_1(object sender, RoutedEventArgs e)
        {

            string value = Tools.ListVievO.ListViewUpravy.getValueSelect("prefix", lstvCeny);
            UpravitRowWin upravitRowWin = new UpravitRowWin(value);
            upravitRowWin.OKClicked += upravitRowWin_OKClicked;
            upravitRowWin.Show();
        }

        void upravitRowWin_OKClicked(object sender)
        {
            DataLib.Settings.databases.dbCeny.loadAllSortTo("prefix", "Ceny", lstvCeny);
        }
    }
}
